cmake_minimum_required(VERSION 3.10)
project(H264-FFMPEG C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include_directories(D:/libraries/ffmpeg-4.3.2-full_build-shared/include)
link_directories(D:/libraries/ffmpeg-4.3.2-full_build-shared/lib)
link_directories(D:/libraries/ffmpeg-4.3.2-full_build-shared/bin)
if(MSVC)
    set(SDL2_DIR D:\\libraries\\MSVC2022\\SDL2-2.32.10\\cmake)
    set(Qt6_DIR C:\\Qt\\6.9.2\\msvc2022_64\\lib\\cmake\\Qt6)
    link_directories(C:\\Qt\\6.9.2\\msvc2022_64\\bin)
    include_directories([=[D:\libraries\MSVC2022\SDL2-2.32.10\include\SDL2]=])
    add_compile_options("/utf-8")
else()
    set(SDL2_DIR D:\\libraries\\MinGW\\SDL2-2.32.2\\cmake)#
    set(Qt6_DIR C:\\Qt\\6.9.2\\mingw_64\\lib\\cmake\\Qt6)
    link_directories(C:\\Qt\\6.9.2\\mingw_64\\bin)
    # include_directories([=[D:\libraries\MinGW\SDL2-2.32.2\x86_64-w64-mingw32\include]=])
endif()
find_package(Qt6 COMPONENTS Core Gui Widgets REQUIRED)
find_package(SDL2 REQUIRED)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
# 设置输出文件名称，debug加d
macro(set_runtime_name target)
if(MSVC)
    if(CMAKE_BUILD_TYPE STREQUAL "Release")
        set_target_properties(${target} PROPERTIES
            RUNTIME_OUTPUT_NAME ${target}_MSVC
        )
    elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
        set_target_properties(${target} PROPERTIES
            RUNTIME_OUTPUT_NAME ${target}d_MSVC
        )
    endif()
else()
    if(CMAKE_BUILD_TYPE STREQUAL "Release")
        set_target_properties(${target} PROPERTIES
            RUNTIME_OUTPUT_NAME ${target}
        )
    elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
        set_target_properties(${target} PROPERTIES
            RUNTIME_OUTPUT_NAME ${target}d
        )
    endif()
endif()
endmacro()
# 设置输出位置
macro(set_out_path target)
    # release
    set_target_properties(${target} PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
    )
    set_target_properties(${target} PROPERTIES
        LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
    )
    set_target_properties(${target} PROPERTIES
        ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
    )
endmacro()
macro(set_fff target)
set_target_properties(${target} PROPERTIES
    WIN32_EXECUTABLE ON
    MACOSX_BUNDLE ON
)
endmacro()
# add_subdirectory(1_ffmpeg_base)
add_subdirectory(2_project)
